<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>03_JS数据类型</title>
</head>
<body>
<script>
    /*
    两种  原始类型+引用数据类型
    原始类型
    1.number（整数 小数0)  string  boolean null undefined(未定义型)
    2.引用 object array function date...*/
    var a= 1;
    var b=9.9;
    console.log(a,typeof  a,b,typeof b);
    var c= 'hello';
    var d="world";
    console.log(c,typeof c,d,typeof d);
    var e=true;
    var f=false;
    console.log(e,typeof e,f,typeof f);
    var g;
    console.log(g,typeof g);

    /*自定义对象*/
    let obj={};
    obj.name='杨硕';
    obj.age=18;
    console.log(obj,typeof obj);//{name:'杨硕',age:18} 'object'
    console.log(obj.name,obj.age);

    /*自定义对象2*/
    let obj2={
        name:'杨硕',
        age:18
        };
    console.log(obj2,typeof obj2);
    console.log(obj2.name,obj2.age);

    /*js数组*/
    let arr=['杨硕',18,true,5.5];
    console.log(arr,typeof arr);
    console.log(arr[0],arr[1],arr[2],arr[3]);
    console.log(arr[999]);/*undefined*/

    /*Number()用于将传入的值转为数字类型
    * 如果得不到数字类型的结果，就会得到NaN（Not a Number）
    */
    console.log(Number(true),typeof Number(true));//1 number
    console.log(Number(false),typeof Number(false));//0 number
    console.log(Number(3));//3 number
    console.log(Number('3'));//3 number
    console.log(Number('杨硕爱吃糖'));//NaN

    /*Boolean()用于将参数转为布尔类型的结果*/
    console.log(Boolean(1),typeof Boolean(1))
    /*0 null NaN  undefined  ''  转为布尔都是false*/
    console.log(Boolean(0));
    console.log(Boolean(null));
    console.log(Boolean(NaN));
    console.log(Boolean(undefined));
    console.log(Boolean(''));
    console.log(Boolean(' '));
    console.log(Boolean('杨硕'));
</script>
</body>
</html>